using System;
using System.Collections.Generic;
using DAL;
using Entity;
using Utilities;

namespace Business
{
	public class InPmsBusiness
	{
		#region code CMS
        //public static List<InPms> GetInPmsList()
        //{
        //    var result = FreshCmsDataAccessProvider.InPms.GetInPmsList();
        //    return result;
        //}

        //public static List<InPms> GetInPmsListByPaging(int pageIndex, int pageSize, ref int totalRecord)
        //{
        //    var result = FreshCmsDataAccessProvider.InPms.GetInPmsListByPaging(pageIndex, pageSize, ref totalRecord);
        //    return result;
        //}

        public static List<InPms> GetInPanelListByGroupId(Int32 groupid)
        {
            var result = FreshCmsDataAccessProvider.InPms.GetInPanelListBGroupId(groupid);
            return result;
        }

        public static InPms GetInPmsById(int pmsId, int panelId)
        {
            var result = FreshCmsDataAccessProvider.InPms.GetInPmsById(pmsId, panelId);
            return result;
        }

        public static InPms CheckInPms(int pmsId, int groupId)
        {
            var result = FreshCmsDataAccessProvider.InPms.CheckInPms(pmsId, groupId);
            return result;
        }
        //public static int InsertInPms(InPms InPms)
        //{
        //    var result = FreshCmsDataAccessProvider.InPms.InsertInPms(InPms);
        //    return result;
        //}

        public static int UpdateInPms(InPms InPms)
        {
            var result = FreshCmsDataAccessProvider.InPms.UpdateInPms(InPms);
            return result;
        }

        //public static int DeleteInPms(int pmsId)
        //{
        //    var result = FreshCmsDataAccessProvider.InPms.DeleteInPms(pmsId);
        //    return result;
        //}


        public static InPms CheckSessionPms(Int32 panelId)
        {
            try
            {
                if (AppSettings.GetInt32("IsLocal")==1)
                    return new InPms{PmsView = 1, PmsUpdate = 1, PmsDelete = 1, GroupId = 1};
                if (System.Web.HttpContext.Current.Session["User"] != null)
                {
                    if (panelId > 0)
                    {
                        InUser user = (InUser)System.Web.HttpContext.Current.Session["User"];
                        return InPmsBusiness.CheckInPms(panelId, user.GroupId);
                    }
                    return null;
                }
            }
            catch (Exception)
            {
                return null;
                throw;
            }
            return null;
        }
		#endregion
	}
}